package org.okwangxing.vsearch.test;

import java.io.File;

import org.okwangxing.vsearch.spring.VSearchApplicationContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * 
 * @author okwangxing
 * @version @(#)AppMain.java 1.0.0 2010-10-17 上午11:39:57
 * @since 1.0
 */
public class AppMain {

	public static void main(String[] args) throws Exception {
		String base = new File("").getAbsolutePath().replace("resource-core", "");
		System.out.println("base home:" + base);
		String jarHome = base + "resouce-client/target/";
		VSearchApplicationContext applicationContext = new VSearchApplicationContext(jarHome, "beans.xml");
		
		
		
		System.out.println("get Beans [person]=>>" + applicationContext.getBean("person"));

		System.out.println("get Beans [zookeepClient]=>>" + applicationContext.loadClass("org.okwangxing.vsearch.iis.IIsZkClient"));
		
		//System.out.println("load ext Beans [zookeepClient]=>>" + applicationContext.getBean("zookeepClient"));
		
		
		ClassPathResource resource = new ClassPathResource(jarHome, applicationContext.getClassLoader());
		BeanFactory factory = applicationContext.getParentBeanFactory();
		XmlBeanFactory beanFactory = new XmlBeanFactory(resource, factory);
		beanFactory.getBean("zookeepClient");

	}
}
